<template>
<div class="myBox">
   <div class="myTitle">
     <span class="mySpan">运费配置</span>
   </div>
   <div class="myBox2">
 <el-form ref="form" class="myform" :rules="formRules" :model="form" label-width="250px">
  <el-form-item  align="center" label="运费满减所需最低消费"  prop='shopping_express_freight_min'>
    <el-input v-model="form.shopping_express_freight_min" class="myinput"></el-input>
  </el-form-item>

  <el-form-item align="center" label="运费满减不足所需运费"  prop='shopping_express_freight_value'>
    <el-input v-model="form.shopping_express_freight_value" class="myinput"></el-input>
  </el-form-item>
  </el-form>
    </div>
      <div class="myfooder">
        <el-button type="primary" @click="editData">确定</el-button>
        <el-button @click="cancel" class="myRight">取消</el-button>
      </div>
 
</div>
</template>
  
<script>
import axios from 'axios'
export default {
  name: 'freightConfig',
  componentTitle: '运费配置',
  data () {
    return {
      token:sessionStorage.getItem('Shopping-Admin-Token'),
      form :{
        shopping_express_freight_value:'',
        shopping_express_freight_min:'',
      },
      formRules: {
        shopping_express_freight_min: [
          {required: true, trigger: 'change'}
        ],
        shopping_express_freight_value: [
          {required: true, trigger: 'change'}
        ],
      },
    }
    
  },
  mounted () {
    this.getData()
  },
  methods:{
    cancel () {
      this.$refs.form.resetFields()
    },
 
    editData () {
      axios({
        url: 'http://192.168.200.251:8888/admin/config/express',
        method: 'post',
        data: {
          ...this.form
        },
        headers: {
          'Shopping-Admin-Token': sessionStorage.getItem('Shopping-Admin-Token')
        }
      }).then(res => {
        if (res.data.errno === 0) {
          this.cancel()
          this.$notify.success({title: '编辑成功'}) 
          this.getData()
        } else {
          this.$notify.error({title: '编辑失败',message:res.data.errmsg})
        }
      })
    },

    getData () {
     axios({
        url: 'http://192.168.200.251:8888/admin/config/express',
        method: 'get',
        params: {
        },
        headers: {
          'Shopping-Admin-Token': sessionStorage.getItem('Shopping-Admin-Token')
        }
      }).then(res => {
        this.form = res.data.data
        console.log(res.data.data)
      })
    },
},
  
}
</script>

<style lang="scss" scoped>

.myBox{
  width: 95%;
  height: 405px;
  background-color: rgb(255, 255, 255);
  margin: 0 auto;
  margin-top: 30px;
   box-shadow: 0px 0px 8px rgb(160, 160, 160);

}

.myTitle{
  height: 55px;
  background-color: rgb(255, 255, 255);
  margin: 0 auto;
  border-bottom: #ddd 1px solid;

  .mySpan{
    line-height: 55px;
    margin-left: 25px;
  }
}

.myBox2{
   display:flex;
   justify-content: center;
}

.myform{
  
  margin-top: 20px;

  .myinput{
    width: 735px;
  }
}


.myfooder{
 width: 100%;
  height: 36px;
text-align: right;

  .myRight{
margin-right: 20px;
  }
}



</style>

